{$subtot = 0}
<table align="center" width="50%">
<tr>
    <th colspan="9">Productos en pedidos</th>
</tr>
<tr id="semana">
    <th>Pieza</th>
    <th>Existencia</th>
{for $count = 0 to 5}
    <th><a href="http://servidor1:82/maquinado/index/ped2/{$smarty.now|date_format:"%W"+$count}">{$smarty.now|date_format:"%W"+$count}</a></th>
{/for}
<th>Total</th>
</tr>
{foreach item='cons' from=$Paroen }
<tr id="">
    <td> {$cons.parte}</td>
    <td> {$cons.exist}</td>
    {for $count = {$smarty.now|date_format:"%W"} to {$smarty.now|date_format:"%W"} + 5}
        {if isset($cons[$count])}
            <td class="{$count}" title="{$count}">{$cons[$count].totsaldo}</td>
            {$subtot = $subtot + $cons[$count].totsaldo}
            {*$max = "max='"|cat:$cons[$count].totsaldo|cat:"'"*}
        {else}
            <td class="{$count}" title="{$count}" >&nbsp;</td>
            {*$max = ""*}
        {/if}
    {/for}
    {if $subtot == 0}
    <td><strong>&nbsp;</strong></td>
    {else}
    <td style="text-align:center;"><strong>{$subtot}</strong></td>
    {/if}
    
    {$subtot = 0}
</tr>
{/foreach}
</table>
<script>
    $(document).ready(function(){
        $('#semana th a').click(function(){
            if($('.'+$(this).text()).text() == '&nbsp;')
                $('.'+$(this).text()).parent().attr('style','display:none;')
        });
    });
</script>